import {API} from '../api/index.js'

/**
 * 获取轮播图
 */
const _ajaxBanner = function() {
    const url = "/mobile/index/ajaxBanner";
    const result = API.post(url);
    return result;
};

/**
 * 获取活动版块
 */
const _ajaxCate=function(){
    const url = "/mobile/index/ajaxCate";
    const result = API.get(url);
    return result;
}


/**
 * 获取商品列表
 * @param {*} param 
 */
const _ajaxGoods=function(param){
    const url = "/mobile/index/ajaxGoods";
    const result = API.post(url,param);
    return result;
}

/**
 * 获取Home侧边菜单
 * @param {*} param 
 */
const _getBrandSeries=function(param){
    const url = "/mobile/index/getBrandSeries";
    const result = API.post(url,param);
    return result;
}


/**
 * 获取商品详情
 * @param {*} id 
 */
const _ajaxdetail=function(id){
    const url="/mobile/goods/ajaxdetail"
    let uid
    if(localStorage.getItem("user")!=null||localStorage.getItem("user")!=undefined){
        uid=JSON.parse(localStorage.getItem("user")).user_id
    }
    const result=API.post(url,{goods_id:id,user_id:uid});
    return result
}

/**
 * 获取商品详细规格
 * @param {*} id 
 */
const _ajaxAttr=function(id){
    const url="/mobile/goods/ajaxAttr"
    const result=API.post(url,{goods_id:id});
    return result
}


/**
 * 登录
 */
const _ajaxlogin=function(param){
    const url="/mobile/user/ajaxlogin"
    const result = API.post(url,param);
    return result
}


/**
 * 获取所有商品列表
 * @param {*} param 
 */
const _getAllGoods=function(param){
    const url="/mobile/index/ajaxAllGoods"
    const result = API.post(url,param);
    return result
}



/**
 * 获取分类活动商品列表
 * @param {*} param 
 */
const _getActivityGoods=function(param){
    const url="/mobile/index/getActivityGoods"
    const result = API.post(url,param);
    return result
}



/**
 * 首页搜索
 * 
 */
const _getGoodsList =function(param){
    const url="/mobile/index/getGoodsList"
    const result=API.post(url,param)
    return result
}





/**
 * 获取隐私条款等文本页面
 * @param {*} param 
 */
const _getDocument =function(param){
    const url="/mobile/user/getDocument"
    const result=API.post(url,param)
    return result
}


/**
 * 获取分享图标
 * @param {*} param 
 */
const _getSharePic =function(param){
    const url="/mobile/article/getSharePic"
    const result=API.post(url,param)
    return result
}



export {
    _ajaxBanner,
    _ajaxCate,
    _ajaxGoods,
    _getBrandSeries,
    _ajaxdetail,
    _ajaxAttr,
    _ajaxlogin,
    _getAllGoods,
    _getActivityGoods,
    _getGoodsList,
    _getDocument,
    _getSharePic
}